package com.jyu.apts.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name="item")
public class Item {
	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE)
	long id;//主键
	@Column
	String name;//名称
	@Column
	String image;
	@Column
	String price;
	@ManyToOne
	Organization organization;
	@OneToMany(mappedBy="item",cascade={CascadeType.REMOVE})//级联删除生产线
	List<ItemProductionLine> itemProductionLines;
	@ManyToMany(mappedBy="items",cascade={CascadeType.REMOVE})//级联删除角色
	List<OrganizationRole> organizationRoles;
	
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public long getId() {
		return id;
	}
}
